package com.hsp.demo_08_object_test;

public class Demo_03 {
    public static void main(String[] args) {
        /*
        编写老师类：
            1、要求有属性：姓名name, 年龄age, 职称post, 基本工资salary
            2、编写业务方法，introduce(), 实现输出一个教师的信息。
            3、编写教师类的三个子类：教授类、副教授类、讲师类。
                工资级别分别为：教授为1.3、 副教授为1.2, 讲师类1.1.
                在三个子类中都重写父类的introduce()方法。
            4、定义并初始化一个老师对象，调用业务方法，实现对象基本信息的后台打印。3
         */
        Teacher t1 = new Teacher("张老师", 35, "高级教师", 18000.0);
        System.out.println(t1.introduce());
        Teacher t2 = new Prefessor("王教授", 53, "教授",26000);
        t2.setLevel(1.3);
        System.out.println(t2.introduce());
    }
}

/**
 * 教授类
 */
class Prefessor extends Teacher{

    public Prefessor() {
    }

    public Prefessor(String name, int age, String post, double salary) {
        super(name, age, post, salary);
    }

    public Prefessor(String name, int age, String post, double salary, double level) {
        super(name, age, post, salary, level);
    }

}

/**
 * 教师类
 */
class Teacher{
    private String name;
    private int age;
    private String post;
    private double salary;
    private double level = 1.0;

    public Teacher(){}

    public Teacher(String name, int age, String post, double salary) {
        this.name = name;
        this.age = age;
        this.post = post;
        this.salary = salary;
    }

    public Teacher(String name, int age, String post, double salary, double level) {
        this.name = name;
        this.age = age;
        this.post = post;
        this.salary = salary;
        this.level = level;
    }

    public String introduce() {
        return "Teacher{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", post='" + post + '\'' +
                ", salary=" + salary * level +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getPost() {
        return post;
    }

    public void setPost(String post) {
        this.post = post;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public double getLevel() {
        return level;
    }

    public void setLevel(double level) {
        this.level = level;
    }
}
